#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''eof
name:申请人与烟草登记负责人不一致
code:Applicant_Not_SmokeRegPerson
tableName:
columnName:
groups:准入>烟商
dependencies:BTM
type:常用指标
dataSourceType:在线指标
description:
eof'''

'''
ratingRequest:取申请人
BTM： 取烟草登记负责人： principal
二者一致返回 1  
负责人或者申请人为null或空时，返回缺失值
'''
import sys
import pandas as pd
import datetime

reload(sys)
sys.setdefaultencoding('utf-8')

def Applicant_Not_SmokeRegPerson():
    null_type_list = ['', None, 'null', 'Null', 'NULL', '/']

    try:
        BTM_ = BTM['data']
    except:
        return u'缺失值'

    try:
       if BTM_.has_key('principal') and BTM_['principal'] not in null_type_list \
        and ratingRequest.has_key('legalPerson') \
        and ratingRequest['legalPerson'] not in null_type_list:
           if BTM_['principal'] == ratingRequest['legalPerson']:
               return 1
           else:
               return 0
       else:
           return u'缺失值'
    
    except:
        return u'缺失值'

result = Applicant_Not_SmokeRegPerson()


